home *** CD-ROM | disk | FTP | other *** search
- FFSEEK(3C) Last changed: 2-18-98
-
-
- NNAAMMEE
- ffffsseeeekk, ffffbbkksspp, ffffsseeeekkff, ffffbbkkssppff - Repositions a flexible file I/O
- file
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ffffiioo..hh>>
-
- ##iinncclluuddee <<uunniissttdd..hh>>
-
- UNICOS and UNICOS/mk systems:
-
- iinntt ffffsseeeekk ((iinntt _f_d,, ooffff__tt _p_o_s,, iinntt _w_h_e_n_c_e [[,, ssttrruucctt ffffssww **_s_t_a_t]]));;
-
- iinntt ffffbbkksspp ((iinntt _f_d [[,, ssttrruucctt ffffssww **_s_t_a_t]]));;
-
- IRIX systems:
-
- ooffff__tt ffffsseeeekk ((iinntt _f_d,, ooffff__tt _p_o_s,, iinntt _w_h_e_n_c_e));;
-
- iinntt ffffbbkksspp ((iinntt _f_d));;
-
- All systems:
-
- ooffff__tt ffffsseeeekkff ((iinntt _f_d,, ooffff__tt _p_o_s,, iinntt _w_h_e_n_c_e,, ssttrruucctt ffffssww **ssttaatt));;
-
- iinntt ffffbbkkssppff ((iinntt _f_d,, ssttrruucctt ffffssww **_s_t_a_t));;
-
- IIMMPPLLEEMMEENNTTAATTIIOONN
- UNICOS, UNICOS/mk, and IRIX systems
-
- DDEESSCCRRIIPPTTIIOONN
- The ffffsseeeekk function provides flexible file I/O (FFIO) positioning
- capability similar to that of llsseeeekk(2). In addition to the
- functionality of llsseeeekk, ffffsseeeekk provides access to limited positioning
- on blocked files and record-oriented files. Specifying ffffsseeeekk((ffdd,, 00,,
- 00)) always rewinds a file to its initial point, regardless of whether
- the file is stream, blocked, or tape. When using the ssyyssccaallll layer,
- this function cannot be used to position a tape.
-
- This function allows programs to be written so that their I/O can be
- controlled by the aassggccmmdd(1) or aassssiiggnn(1) command. Both native and
- foreign record-oriented I/O, multifile datasets, and
- performance-oriented layers (such as SDS resident layers and
- memory-resident layers) are available with this mechanism.
-
- Function ffffbbkksspp allows you to perform a backspace operation on those
- FFIO layers that support it. Currently, this is limited to ccooss, ttaappee,
- ff7777, and tteexxtt.
-
- Arguments are as follows:
-
- _f_d Number returned by ffffooppeenn(3C).
-
- _p_o_s Byte position requested.
-
- _w_h_e_n_c_e Specifies one of the following values (defined in header file
- ssttddiioo..hh):
-
- 0 or SSEEEEKK__SSEETT Sets the pointer to the value of _p_o_s.
- _p_o_s must be a non-negative integer.
- (Special case: ffffsseeeekk((ffdd,, 00,, 00)) ==
- rreewwiinndd)
-
- 11 or SSEEEEKK__CCUURR Sets the pointer to the current position,
- plus or minus **_a_r_g. This is supported
- only in layers that are not
- record-oriented; layers are specified to
- aassssiiggnn --FF as follows: ssyyssccaallll, ssddss, mmrr
- (memory resident), ccaacchhee, ccaacchheeaa, bbuuffaa,
- eerr9900.
-
- 22 or SSEEEEKK__EENNDD Sets the pointer to the end of the file,
- minus _p_o_s. _p_o_s must be a non-negative
- integer. Not all layers support this
- option. (Special case: ffffsseeeekk((ffdd,, 00,, 22))
- == position just in front of the EOD.)
-
- ssttaatt Pointer to the ffffssww status return structure.
-
- RREETTUURRNN VVAALLUUEESS
- The return value is the current position in the file after the seek.
- Upon successful completion, a non-negative value is returned.
- Otherwise, -1 is returned, and, if the _s_t_a_t parameter is passed, the
- error value is found in ssttaatt..ssww__eerrrroorr. If the _s_t_a_t parameter is not
- provided, the error code is found in eerrrrnnoo.
-
- EEXXAAMMPPLLEESS
- #include <stdlib.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <ffio.h>
-
- main()
- {
- size_t ret;
- int fd, i, j;
- off_t fret;
-
- fd = ffopen("data", O_RDWR | O_CREAT, 0666);
-
- for (i = 0 ; i < 1000 ; i++)
- {
- ret = ffwrite(fd, &i, sizeof(i));
- if (ret < 0) abort();
- }
-
- for (i = 0 ; i < 10 ; i++)
- {
- fret = ffseek(fd, i * sizeof(j) * 100, SEEK_SET);
- if (fret < 0) abort();
- ret = ffread(fd, &j, sizeof(j));
- if (ret < 0) abort();
- printf("Value is %d at word %d\n", j, i*100);
- }
- }
-
- Output from the previous program is as follows:
-
- Value is 0 at word 0
- Value is 100 at word 100
- Value is 200 at word 200
- Value is 300 at word 300
- Value is 400 at word 400
- Value is 500 at word 500
- Value is 600 at word 600
- Value is 700 at word 700
- Value is 800 at word 800
- Value is 900 at word 900
-
- SSEEEE AALLSSOO
- eerrrrnnoo..hh(3C), ffffcclloossee(3C), ffffooppeenn(3C), ffffrreeaadd(3C), ffffwwrriittee(3C)
-
- _A_p_p_l_i_c_a_t_i_o_n _P_r_o_g_r_a_m_m_e_r'_s _L_i_b_r_a_r_y _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication
- SR-2165, for the printed version of this man page.
-